

*For Margaret dropbox folders 
global NCREIF "/Users/BeckaBrolinson/Dropbox/NCREIF/data" 
global build 	"$NCREIF/build" 
global analysis "$NCREIF/analysis"
global results 	"$analysis/results"
global figures 	"$analysis/figures"  

*------------------------------------------------------------------------------*
*	Step 18- Effect of Certification on Occupancy Rates *
*------------------------------------------------------------------------------*	


*Run the FE regression of real util per sqft on treat*post 
set more off 

	#d ;
	global Cov0 	""; 
	global Cov1 	"Covered_E real_elecprice real_gasprice Unemployment HDD1000s CDD1000s 
	age age2 sqft1000s
	real_capex_ti_sqft real_capex_bldimp_sqft "; 
	global Cov2 	"Covered_E real_elecprice real_gasprice Unemployment HDD1000s CDD1000s
	 age age2 sqft1000s
	dFundType1 dFundType2 dFundType4 dFundType5 dFundType6";
	global Cov3	"Covered_E real_elecprice Unemployment HDD1000s CDD1000s 
	age age2 sqft1000s"; 
	#d cr 

	**DIFF IN DIFF 
	use "$build/FakeNCREIFAnnualizedDatawcontrol_PostMatch2_wmatches.dta", clear 
	
	gen sqft1000s = sqft / 1000 
	gen HDD1000s = HDD / 1000 
	gen CDD1000s = CDD / 1000 
	gen used_space1000s = used_space/ 1000
	gen real_capex_ti_sqft = real_capex_ti / sqft 
	gen real_capex_bldimp_sqft = real_capex_bldimp / sqft 

	
	*label variables for regression tables 	
	label var interaction "Cert*Post" 
	label var treat "1[treat=1]"
	label var logrealrentpersf "ln(Rent/Sq. Ft.) (\\$)"
	label var Covered_E "Benchmarking Law" 
	label var real_elecprice "Avg. Elec. Price (\\$/MWh)" 
	label var real_gasprice "Avg. Gas Price (\\$/Mcf)" 
	label var Unemployment "Unemployment" 
	label var age "Building Age" 
	label var age2 "Building Age Squared" 
	label var used_space "Used Space (Pct. Leased * Sq. Ft.)"
	label var used_space1000s "Used Space (Pct. Leased * Sq. Ft.) (1000s)"
	labe var percentleased "Percent Leased (\%)"
	label var real_capex_ti "Cap Exp. (Tenant Imp.)" 
	label var real_capex_ti_sqft "Cap Exp./Sq. Ft. (Tenant Imp.) (\\$)"
	label var real_capex_bldimp "Cap Exp. (Bldg. Imp.)"
	label var real_capex_bldimp_sqft "Cap Exp./Sq. Ft. (Bldg. Imp.) (\\$)"
	label var HDD "HDD" 
	label var HDD1000s "HDD (1000s)" 
	label var CDD "CDD" 
	label var CDD1000s "CDD (1000s)" 
	label var rl_yr_rentpersf "Rent per Sq. Ft."
	label var logrealutilpersf "ln(Util/Sq. Ft.) (\\$)"
	label var rl_yr_rentpersf "Rent per Sq. Ft."
	label var rl_yr_utilpersf "Util. per Sq. Ft."
	label var yrbuilt "Year Built" 
	label var sqft "Square Feet"
	label var sqft1000s "Square Feet (1000s)" 
	
*using hdfe 
	local Covariates "Cov0 Cov1 Cov2 Cov3" 
	foreach Cov of local Covariates{
	eststo UtilFE1: reghdfe percentleased interaction i.treat, absorb(i.city_cat#i.year) vce(cluster cbsa)
	estfe  UtilFE1, labels(year "Year FE" city_cat#year "City by Year FE")
	eststo UtilCov1_FE: reghdfe percentleased interaction i.treat rl_yr_rentpersf rl_yr_utilpersf $Cov1 , absorb(i.city_cat#i.year) vce(cluster cbsa)
	estfe  UtilCov1_FE, labels(year "Year FE" city_cat#year "City by Year FE")
	eststo UtilFE`Cov': reghdfe percentleased interaction rl_yr_rentpersf rl_yr_utilpersf  $`Cov' , absorb(i.propnum i.city_cat#i.year) vce(cluster cbsa)
	estfe  UtilFE`Cov', labels(year "Year FE" city_cat#year "City by Year FE" propnum "Property FE")
	}
	
			
	*make Latex Table 
	esttab UtilFE1 UtilCov1_FE UtilFECov1 UtilFECov3 using "$results/16_pctleased_matched2.tex" , label replace booktabs ///
	alignment(SSSS) ///
	b(%12.3f) se(%12.3f) star(* 0.05) /// sets format of parameters, standard errors, and stars
	stats(N, fmt(%9.0fc)) /// adds comma to Observation number
	nonotes nogaps /// removes notes from bottom of table 
	indicate(`r(indicate_fe)', label("Y" "")) /// adds y & N for FE inclusions
	title(Matched Sample: Energy Star Certification and Utility Expenditure Per Sq. Ft. \label{tab16pctleasedmatched2}) ///
	addnote({\scriptsize * p$<$0.05. The standard errors reported in parenthesis have been clustered at the CBSA level.})
	
